home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Spanish Scene 1
/
SpanishScene1.iso
/
spanish pack n°1 by llfb
/
--llfb--
/
programas
/
sources1.dms
/
sources1.adf
/
SOURCES
/
Rutinas_de_lineas
/
68000_DrawLine.ASM
next >
Wrap
Assembly Source File
|
1996-06-04
|
2KB
|
104 lines
* Lately there has been a few requests for a mythical very fast line
* drawing routine, posted to a comp.sys.amiga.* news group some time in
* the past, this is not it.
* This is, however, a good line drawing routine written by me, and
* using Bresenham's line drawing algorithm taken from,
* Computer Graphics, Donald Hearn, M. Pauline Baker
* published by Prentice-Hall International.
* It also produces lines identicle to lines drawn by the blitter.
*
* Stuart Twyford
* Internet: int131d@monu3.cc.monash.edu.au
*
* Bresenham_line:
* INPUT:
* d0<31-16> Y cordinate of start point
* d0<15-0> X cordinate of start point
* d1<31-16> Y cordinate of end point
* d1<15-0> X cordinate of end point
* a0 pointer to bit plane
*
* USES:
* d0-d7
* a0-a1
Bresenham_line:
move.w #1,d6
sub.w d0,d1
bge.s .got_deltaX
neg.w d1
neg.w d6
.got_deltaX:
swap d0
move.w d1,d2
swap d1
move.w #Width_in_bytes,d7
sub.w d0,d1
bge.s .got_deltaY
neg.w d1
neg.w d7
.got_deltaY:
clr.w d5
cmp.w d1,d2
bge.s .got_L_and_Sdelta
swap d1
not.w d5
.got_L_and_Sdelta:
move.w d0,d2
mulu #Width_in_bytes,d2
adda.w d2,a0
swap d0
movea.w d7,a1
move.w d1,d2
swap d1
add.w d2,d2
move.w d2,d3
sub.w d1,d3
move.w d3,d4
sub.w d1,d4
tst.w d5
bne.s .deltaY_greater
.next_X:
move.w d0,d7
not.w d7
move.w d0,d5
asr.w #3,d5
bset d7,(a0,d5.w)
tst.w d1
beq.s .line_done
subq.w #1,d1
add.w d6,d0
tst.w d3
bge.s .add_d4_to_Y
add.w d2,d3
bra.s .next_X
.add_d4_to_Y:
adda.w a1,a0
add.w d4,d3
bra.s .next_X
.deltaY_greater:
.next_Y:
move.w d0,d7
not.w d7
move.w d0,d5
asr.w #3,d5
bset d7,(a0,d5.w)
tst.w d1
beq.s .line_done
subq.w #1,d1
adda.w a1,a0
tst.w d3
bge.s .add_d4_to_X
add.w d2,d3
bra.s .next_Y
.add_d4_to_X:
add.w d6,d0
add.w d4,d3
bra.s .next_Y
.line_done:
rts